import 'package:flutter/material.dart';
import 'package:flutter_color_plugin/flutter_color_plugin.dart';


class AppBarWidget extends StatelessWidget  implements PreferredSizeWidget {
  final Color bgColor; //导航栏背景颜色
  final double elev; // 沉浸式状态栏
  final IconData icon; //图标
  final Color iconColor;//图标颜色
  final Function fun; //点击的回调
  final String title;

  const AppBarWidget({Key key, @required this.bgColor , this.elev = 0, this.icon = Icons.navigate_before,
   this.iconColor = Colors.white, this.fun, this.title = ''}) : super(key: key);
  @override
  Widget build(BuildContext context) {
    // 获取屏幕的高度
return AppBar(
    elevation: elev,
    backgroundColor: bgColor,
    centerTitle: true,
    title: Text(title,style: TextStyle(color: iconColor,fontSize: 18,fontWeight: FontWeight.bold),),
    leading: GestureDetector(
      child: IconButton(
        icon: Icon(
          icon,
          color: iconColor,
        ),
        onPressed:(){
          Navigator.pop(context);
        },
      ),
    ),
  );
  }

  @override
  // TODO: implement preferredSize
  Size get preferredSize => getSize();

  Size  getSize() {
     return new Size(100, 40);
  }
}
